<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<div id="tree_1" class="tree-demo">
    <ul>
        <li data-jstree='{ "opened" : true ,"icon" : "fa fa-asterisk fa-spin icon-state-info"}' data-id=""  data-name="顶级目录">
            ${parkName}
            <ul>
                <c:forEach items="${berths}" step="1" varStatus="status" var="berth">
                    <li data-id="${berth.id}"     data-jstree='{ "selected" : ${berth.selected},"disabled" : ${berth.disabled}}'>
                            ${berth.berthCode}
                    </li>
                </c:forEach>

            </ul>
        </li>
    </ul>
</div>

<script>

    $("#tree_1").ready(function () {
        $("#tree_1").jstree({
            'plugins': ["checkbox", "types"],
            "core": {
                "themes": {
                    "responsive": false
                }
            }
        });

    });

    /**
     * 获取全部选中节点
     */
    function getAllCheckedPower() {
        var checkedArray = new Array();

        /**
         * 获取选中节点
         * */
        var checkeds = $('#tree_1').jstree().get_checked(true);
        for (var c in checkeds) {
            checkedArray.push(checkeds[c].data["id"]);
        }

        /**
         * 获取父级节点
         */
      /*  $("#tree_1").find("li").each(function () {
            var lii = $(this).find("a").eq(0).find("i").eq(0);
            if (lii.hasClass("jstree-undetermined")) {
                var id = $(this).data("id");
                if (id != undefined) {
                    checkedArray.push(id);
                }
            }
        });*/

        return checkedArray;
    }
</script>
